package com.example.mapper;

import com.example.entity.Booking;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Select;

import java.util.Date;
import java.util.List;

public interface BookingMapper {
    List<Booking> selectAll(Booking booking);
    
    @Select("select b.*, u.username as userName, h.name as hotelName, r.room_type as roomType " +
           "from `booking` b " +
           "left join `user` u on b.user_id = u.id " +
           "left join `hotel` h on b.hotel_id = h.id " + 
           "left join `room` r on b.room_id = r.id " +
           "where b.id = #{id}")
    Booking selectById(Long id);
    
    void insert(Booking booking);
    
    void updateById(Booking booking);
    
    @Delete("delete from `booking` where id = #{id}")
    void deleteById(Long id);
    
    List<Booking> selectByUserId(Long userId);
    
    List<Booking> selectByDateRange(Long roomId, String startDate, String endDate);
}